//
//  LoggerEventMonitor.swift
//  SwiftCode
//
//  Created by yuhus on 2024/7/26.
//

import Foundation
import Alamofire

final class LoggerEventMonitor: EventMonitor {
  let queue = DispatchQueue(label: "com.coder.alamofire")
  
  // 恢复任何类型的请求时调用的事件。
  func requestDidResume(_ request: Request) {
    Timber.d("🟢: \(request)")
  }
  
  func request(_ request: DataRequest, didParseResponse response: DataResponse<Data?, AFError>) {
    Timber.d("🟡: \(response.debugDescription)")
  }
  
  // 每当 DataRequest 解析响应时调用的事件。
  func request<Value>(_ request: DataRequest, didParseResponse response: DataResponse<Value, AFError>) {
    Timber.d("🔴: \(response.debugDescription)")
  }
  
  func requestDidFinish(_ request: Request) {
    Timber.d("🔴: ")
  }
}
